#include <iostream>
#include <unistd.h>
#include <signal.h>
#include <cassert>
#include <sys/types.h>
#include <sys/wait.h>

using namespace std;

int main()
{
    int id = fork();
    assert(id >= 0);
    if (id == 0)
    {
        int n = 10;
        n /= 0;
    }

    int status = 0;
    waitpid(id, &status, 0);

    cout << "signal: " << (status & 0x7f) << endl;
    cout << "core dump flag: " << ((status >> 7) & 1) << endl;

    return 0;
}